/**
 * Octopus, an XMMS2 client.
 * Copyright (C) 2014 Octopus Team
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

namespace OctopusUi {
	public class UiPropertiesDialog : Gtk.Dialog {
		public signal void layout (LayoutEnum layout);
		public signal void css (string css_file);

		public UiPropertiesDialog () {
			this.title = "Octopus - Properties";
			this.border_width = 5;
			set_resizable (false);

			Gtk.Box content = get_content_area () as Gtk.Box;
			Gtk.Box vbox = new Gtk.Box (Gtk.Orientation.VERTICAL, 10);
			content.add (vbox);

			Gtk.Frame layout_frame = new Gtk.Frame ("Layout");
			vbox.add (layout_frame);
			var layout_hbox = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 10);
			layout_frame.add (layout_hbox);

			var iconfile_grid = GLib.Path.build_filename (Octopus.Global.get ().data_path, "octopus", "img", "2d_200x100.png");
			Gtk.Image image_grid = new Gtk.Image ();
			image_grid.set_from_file (iconfile_grid);
			var button_grid = new Gtk.RadioButton (null);
			button_grid.set_image (image_grid);
			button_grid.clicked.connect (() => {
				layout (LayoutEnum.GRID);
			});
			layout_hbox.add (button_grid);

			var iconfile_deformed = GLib.Path.build_filename (Octopus.Global.get ().data_path, "octopus", "img", "3d_200x100.png");
			Gtk.Image image_deformed = new Gtk.Image ();
			image_deformed.set_from_file (iconfile_deformed);
			var button_deformed = new Gtk.RadioButton.from_widget (button_grid);
			button_deformed.set_image (image_deformed);
			button_deformed.clicked.connect (() => {
				layout (LayoutEnum.DEFORMED);
			});
			layout_hbox.add (button_deformed);

			if (Octopus.Global.get ().get_configure ().has_key ("ui", "layout")) {
				switch (Octopus.Global.get ().get_configure ().get_integer("ui", "layout")) {
					case LayoutEnum.GRID:
						button_grid.set_active (true);
						break;
					case LayoutEnum.DEFORMED:
						button_deformed.set_active (true);
						break;
				}
			} else {
				//default layout
				button_deformed.set_active (true);
			}

//			var css_hbox = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 10);
//			vbox.add (css_hbox);
//			var css_label = new Gtk.Label ("Style");
//			css_hbox.add (css_label);
//			Gtk.ComboBoxText css_combobox = new Gtk.ComboBoxText ();
//			css_combobox.append_text ("1.css");
//			css_combobox.append_text ("2.css");
//			css_combobox.append_text ("3.css");
//			css_combobox.active = 0;
//			css_hbox.add (css_combobox);
//			css_combobox.changed.connect (() => {
//				css (css_combobox.get_active_text ());
				//Mx.Style.get_default ().load_from_file ("/usr/share/octopus/simple/style/white.css");
//			});
		}

		~UiPropertiesDialog () {
			GLib.debug ("~UiPropertiesDialog");
		}
	}
}
